// 网络连接状态检测工具

// 监听网络状态变化
export const setupNetworkMonitor = (onlineCallback, offlineCallback) => {
  const handleOnline = () => {
    console.log('网络已连接');
    if (onlineCallback) onlineCallback();
  };
  
  const handleOffline = () => {
    console.log('网络已断开');
    if (offlineCallback) offlineCallback();
  };
  
  window.addEventListener('online', handleOnline);
  window.addEventListener('offline', handleOffline);
  
  // 返回清理函数
  return () => {
    window.removeEventListener('online', handleOnline);
    window.removeEventListener('offline', handleOffline);
  };
}; 